<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/mui2.css">
		<link rel="stylesheet" href="../css/pravate/updateLoginPass.css">
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/jquery-2.1.0.js"></script>
		<script type="text/javascript" src="../js/mobile-detect.min.js" ></script>
		<script type="text/javascript" src="../js/config.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
	</head>
	<style type="text/css">
		.mui-input-group input,
		.mui-input-group .mui-input-row {
			border: 1px solid #F9F9F9;
		}
		
		.mui-input-group input::-moz-placeholder {
			font-size: 15px;
		}
		
		.mui-input-group input::-webkit-input-placeholder {
			font-size: 15px;
		}
		
		.mui-input-group .mui-input-row:after,
		.mui-input-group:after {
			height: 0;
		}
		
		.btn_hui {
			background-color: #C9C9C9 !important;
			border-color: #c9c9c9 !important;
		}
	</style>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">修改登录密码</h1>
		</header>
		<div class="main" style="padding: 0 10px;">
			<div id="div1">
				<form class="mui-input-group">
					<div class="mui-input-row" style="display: flex;flex-flow: row;">
						<input type="text" class="mui-input-clear" placeholder="输入验证码" data-id="验证码" style="flex: 1;">
						<div class="mui-btn mui-btn-warning yzm" style="width: 100px;font-size: 16px;">验证码</div>
					</div>
				</form>
			</div>
			<span class="xiaozi">
			密码由6-20位字符组成
		</span>
			<div id="div2">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<input type="password" class="mui-input-clear" data-id="新登录密码" placeholder="输入新登录密码">
					</div>
					<div class="mui-input-row">
						<input type="password" class="mui-input-clear" data-id="确认密码" placeholder="确认新登录密码">
					</div>
				</form>
			</div>
			<div id="div3">
				<a href="rzkb.html"><button type="button" class="mui-btn mui-btn-primary" id="confirm">完成</button></a>
			</div>
		</div>
		<script>
			var status = "false";
			var time = 60;
			//点击发送验证码
			mui("body").on("tap", ".yzm", function() {
				$("input").blur();
				if(status == "false") {
					var that = $(this);
					status = "true";
					plus.nativeUI.showWaiting("正在发送验证码，请勿退出...");
					that.addClass("btn_hui");
					require(weburl + model_sendY, "json", "post", {
						phone: localStorage.getItem("USERID"),
						token: localStorage.getItem("token")
					}, function(e) {
						console.log(JSON.stringify(e));
						plus.nativeUI.closeWaiting();
						if(e.status == "success") {
							var time_terval = setInterval(function() {
								if(time > 0) {
									that.html(time + "s后重发");
									time--;
								} else {
									that.html("验证码");
									that.removeClass("btn_hui");
									status = "false";
									time = 60;
									clearInterval(time_terval);
								}
							}, 1000)
							mui.alert(e.msg, " ", "关闭", function() {}, "div");
						} else {
							status = "false";
							that.removeClass("btn_hui");
							mui.alert(e.msg, " ", "关闭", function() {}, "div");
						}
					}, function(e) {
						status = "false";
						that.removeClass("btn_hui");
						mui.alert("发送验证码失败，请稍后再试", " ", "关闭", function() {}, "div");
					})
				}
			})
			//点击完成
			mui("body").on("tap", "#confirm", function() {
				$("input").blur();
				if(!$("input")) {
					mui.alert($(this).attr("data-id") + "不能为空", " ", "确认", function() {
						return false;
					}, "div");
				} else {
					console.log($("input").eq(0).val());
					require(weburl + model_modify, "json", "post", {
						token: localStorage.getItem("token"),
						phone: localStorage.getItem("USERID"),
						password: $("input").eq(1).val(),
						verification_code: $("input").eq(0).val(),
						password_confirmation: $("input").eq(2).val()
					}, function(e) {
						console.log(JSON.stringify(e));
						if(e.status == "success") {
							mui.alert(e.msg, " ", "确认", function() {}, "div");
							$("input").val("");
							return false;
						}
						mui.alert(e.msg, " ", "关闭", function() {}, "div");
					}, function() {
						mui.alert("修改登录密码失败", " ", "关闭", function() {}, "div");
					})
				}
			})
		</script>
	</body>

</html>